package cn.javass.dp.strategy.example5;

public class Client {
    public static void main(String[] args) {
        PaymentStrategy strategyRMB = new RMBCash();
        PaymentStrategy strategyDollar = new DollarCash();

        PaymentContext ctx1 = new PaymentContext("小李", 5000 , strategyRMB);
        PaymentContext ctx2 = new PaymentContext("小李1", 56000 , strategyDollar);

        ctx1.payNow();
        ctx2.payNow();

        //2种上下文扩展的方式

        // 第一种  如果数据越来越多 容易上下文层次复杂
         /*     PaymentStrategy strategyCard = new CardCash();
        PaymentContext ctx3 = new PaymentContext2("小李2", 25000 , strategyCard,"3434343");
        ctx3.payNow();*/

         //对于客户端不友好
        PaymentStrategy card = new Card2Cash("12331231");
        PaymentContext ctx4 = new PaymentContext("小李2", 25000 , card);
        ctx4.payNow();
    }
}
